package com.bruce.pattern.behavioral.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * 课程集合
 * <p>
 * Created by bruce on 2018/11/10 13:28
 */
public class CourseAggregateImpl<E> implements CourseAggregate<E> {

    private List<E> list;

    public CourseAggregateImpl() {
        //采用什么样的数据结构任意
        this.list = new ArrayList<>();
    }

    @Override
    public void addCourse(E item) {
        list.add(item);
    }

    @Override
    public void removeCourse(E item) {
        list.remove(item);
    }

    @Override
    public CourseIterator<E> getIterator() {
        return new CourseIteratorImpl<>(list);
    }

}
